package opera;

import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: DickYang
 * Date: 2023-05-28
 * Time: 10:40
 */
public class FindOperation implements IOPeration {
    @Override
    public void work(BookList bookList) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入查找图书名:");
        String name = scanner.nextLine();

        for (int i = 0; i < bookList.getUserSize(); i++) {
            if (name.equals(bookList.getBooks(i).getName())) {
                System.out.println(bookList.getBooks(i).toString());
                return;
            }
        }
        System.out.println("查无此书!");
    }
}
